
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/sets.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:25:41 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Sets &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../_static/sympy-notailtext-favicon.ico"/>
    <link href="sets.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Simplify" href="simplify/index.html" />
    <link rel="prev" title="Limits of Sequences" href="series/limitseq.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="simplify/index.html" title="Simplify"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="series/limitseq.html" title="Limits of Sequences"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Sets</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="sets">
<h1>Sets<a class="headerlink" href="#sets" title="Permalink to this headline">¶</a></h1>
<section id="module-sympy.sets.sets">
<span id="basic-sets"></span><h2>Basic Sets<a class="headerlink" href="#module-sympy.sets.sets" title="Permalink to this headline">¶</a></h2>
<section id="set">
<h3>Set<a class="headerlink" href="#set" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.Set">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">Set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L38-L693"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set" title="Permalink to this definition">¶</a></dt>
<dd><p>The base class for any kind of set.</p>
<p class="rubric">Explanation</p>
<p>This is not meant to be used directly as a container of items. It does not
behave like the builtin <code class="docutils literal notranslate"><span class="pre">set</span></code>; see <a class="reference internal" href="#sympy.sets.sets.FiniteSet" title="sympy.sets.sets.FiniteSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">FiniteSet</span></code></a> for that.</p>
<p>Real intervals are represented by the <a class="reference internal" href="#sympy.sets.sets.Interval" title="sympy.sets.sets.Interval"><code class="xref py py-class docutils literal notranslate"><span class="pre">Interval</span></code></a> class and unions of
sets by the <a class="reference internal" href="#sympy.sets.sets.Union" title="sympy.sets.sets.Union"><code class="xref py py-class docutils literal notranslate"><span class="pre">Union</span></code></a> class. The empty set is represented by the
<a class="reference internal" href="#sympy.sets.sets.EmptySet" title="sympy.sets.sets.EmptySet"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmptySet</span></code></a> class and available as a singleton as <code class="docutils literal notranslate"><span class="pre">S.EmptySet</span></code>.</p>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.boundary">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">boundary</span></span><a class="headerlink" href="#sympy.sets.sets.Set.boundary" title="Permalink to this definition">¶</a></dt>
<dd><p>The boundary or frontier of a set.</p>
<p class="rubric">Explanation</p>
<p>A point x is on the boundary of a set S if</p>
<ol class="arabic simple">
<li><p>x is in the closure of S.
I.e. Every neighborhood of x contains a point in S.</p></li>
<li><p>x is not in the interior of S.
I.e. There does not exist an open set centered on x contained
entirely within S.</p></li>
</ol>
<p>There are the points on the outer rim of S.  If S is open then these
points need not actually be contained within S.</p>
<p>For example, the boundary of an interval is its start and end points.
This is true regardless of whether or not the interval is open.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">boundary</span>
<span class="go">{0, 1}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">boundary</span>
<span class="go">{0, 1}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.closure">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">closure</span></span><a class="headerlink" href="#sympy.sets.sets.Set.closure" title="Permalink to this definition">¶</a></dt>
<dd><p>Property method which returns the closure of a set.
The closure is defined as the union of the set itself and its
boundary.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="o">.</span><span class="n">closure</span>
<span class="go">Reals</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">closure</span>
<span class="go">Interval(0, 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.complement">
<span class="sig-name descname"><span class="pre">complement</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">universe</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L169-L184"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.complement" title="Permalink to this definition">¶</a></dt>
<dd><p>The complement of ‘self’ w.r.t the given universe.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">complement</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Union(Interval.open(-oo, 0), Interval.open(1, oo))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">complement</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">UniversalSet</span><span class="p">)</span>
<span class="go">Complement(UniversalSet, Interval(0, 1))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.contains">
<span class="sig-name descname"><span class="pre">contains</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L293-L338"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a SymPy value indicating whether <code class="docutils literal notranslate"><span class="pre">other</span></code> is contained
in <code class="docutils literal notranslate"><span class="pre">self</span></code>: <code class="docutils literal notranslate"><span class="pre">true</span></code> if it is, <code class="docutils literal notranslate"><span class="pre">false</span></code> if it isn’t, else
an unevaluated <code class="docutils literal notranslate"><span class="pre">Contains</span></code> expression (or, as in the case of
ConditionSet and a union of FiniteSet/Intervals, an expression
indicating the conditions for containment).</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>As a shortcut it is possible to use the ‘in’ operator, but that
will raise an error unless an affirmative true or false is not
obtained.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">(0 &lt;= x) &amp; (x &lt;= 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="ow">in</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">TypeError</span>: <span class="n">did not evaluate to a bool: None</span>
</pre></div>
</div>
<p>The result of ‘in’ is a bool, not a SymPy value</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span> <span class="ow">in</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">_</span> <span class="ow">is</span> <span class="n">S</span><span class="o">.</span><span class="n">true</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.inf">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">inf</span></span><a class="headerlink" href="#sympy.sets.sets.Set.inf" title="Permalink to this definition">¶</a></dt>
<dd><p>The infimum of <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">inf</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">inf</span>
<span class="go">0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.interior">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">interior</span></span><a class="headerlink" href="#sympy.sets.sets.Set.interior" title="Permalink to this definition">¶</a></dt>
<dd><p>Property method which returns the interior of a set.
The interior of a set S consists all points of S that do not
belong to the boundary of S.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">interior</span>
<span class="go">Interval.open(0, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">boundary</span><span class="o">.</span><span class="n">interior</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.intersect">
<span class="sig-name descname"><span class="pre">intersect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L116-L135"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.intersect" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the intersection of ‘self’ and ‘other’.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">Interval(1, 2)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">imageset</span><span class="p">,</span> <span class="n">Lambda</span><span class="p">,</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">n</span><span class="p">,</span> <span class="n">m</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;n m&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">imageset</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">n</span><span class="p">),</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">imageset</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">m</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">))</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.intersection">
<span class="sig-name descname"><span class="pre">intersection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L137-L141"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.intersection" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for <a class="reference internal" href="#sympy.sets.sets.Set.intersect" title="sympy.sets.sets.Set.intersect"><code class="xref py py-meth docutils literal notranslate"><span class="pre">intersect()</span></code></a></p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.is_closed">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_closed</span></span><a class="headerlink" href="#sympy.sets.sets.Set.is_closed" title="Permalink to this definition">¶</a></dt>
<dd><p>A property method to check whether a set is closed.</p>
<p class="rubric">Explanation</p>
<p>A set is closed if its complement is an open set. The closedness of a
subset of the reals is determined with respect to R and its standard
topology.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">is_closed</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.is_disjoint">
<span class="sig-name descname"><span class="pre">is_disjoint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L143-L161"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.is_disjoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if <code class="docutils literal notranslate"><span class="pre">self</span></code> and <code class="docutils literal notranslate"><span class="pre">other</span></code> are disjoint.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">is_disjoint</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">is_disjoint</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r688"><span class="brackets"><a class="fn-backref" href="#id1">R688</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Disjoint_sets">https://en.wikipedia.org/wiki/Disjoint_sets</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.is_open">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_open</span></span><a class="headerlink" href="#sympy.sets.sets.Set.is_open" title="Permalink to this definition">¶</a></dt>
<dd><p>Property method to check whether a set is open.</p>
<p class="rubric">Explanation</p>
<p>A set is open if and only if it has an empty intersection with its
boundary. In particular, a subset A of the reals is open if and only
if each one of its points is contained in an open interval that is a
subset of A.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="o">.</span><span class="n">is_open</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">Rationals</span><span class="o">.</span><span class="n">is_open</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.is_proper_subset">
<span class="sig-name descname"><span class="pre">is_proper_subset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L414-L431"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.is_proper_subset" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if <code class="docutils literal notranslate"><span class="pre">self</span></code> is a proper subset of <code class="docutils literal notranslate"><span class="pre">other</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span><span class="o">.</span><span class="n">is_proper_subset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">is_proper_subset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.is_proper_superset">
<span class="sig-name descname"><span class="pre">is_proper_superset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L459-L476"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.is_proper_superset" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if <code class="docutils literal notranslate"><span class="pre">self</span></code> is a proper superset of <code class="docutils literal notranslate"><span class="pre">other</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">is_proper_superset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">is_proper_superset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.is_subset">
<span class="sig-name descname"><span class="pre">is_subset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L350-L397"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.is_subset" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if <code class="docutils literal notranslate"><span class="pre">self</span></code> is a subset of <code class="docutils literal notranslate"><span class="pre">other</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span><span class="o">.</span><span class="n">is_subset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">is_subset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">left_open</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.is_superset">
<span class="sig-name descname"><span class="pre">is_superset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L433-L450"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.is_superset" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if <code class="docutils literal notranslate"><span class="pre">self</span></code> is a superset of <code class="docutils literal notranslate"><span class="pre">other</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span><span class="o">.</span><span class="n">is_superset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">is_superset</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">left_open</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.isdisjoint">
<span class="sig-name descname"><span class="pre">isdisjoint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L163-L167"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.isdisjoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for <a class="reference internal" href="#sympy.sets.sets.Set.is_disjoint" title="sympy.sets.sets.Set.is_disjoint"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_disjoint()</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.issubset">
<span class="sig-name descname"><span class="pre">issubset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L408-L412"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.issubset" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for <a class="reference internal" href="#sympy.sets.sets.Set.is_subset" title="sympy.sets.sets.Set.is_subset"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_subset()</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.issuperset">
<span class="sig-name descname"><span class="pre">issuperset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L453-L457"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.issuperset" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for <a class="reference internal" href="#sympy.sets.sets.Set.is_superset" title="sympy.sets.sets.Set.is_superset"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_superset()</span></code></a></p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.measure">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#sympy.sets.sets.Set.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>The (Lebesgue) measure of <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">measure</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">measure</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.powerset">
<span class="sig-name descname"><span class="pre">powerset</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L482-L515"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.powerset" title="Permalink to this definition">¶</a></dt>
<dd><p>Find the Power set of <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">EmptySet</span><span class="p">,</span> <span class="n">FiniteSet</span><span class="p">,</span> <span class="n">Interval</span>
</pre></div>
</div>
<p>A power set of an empty set:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">EmptySet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">powerset</span><span class="p">()</span>
<span class="go">{EmptySet}</span>
</pre></div>
</div>
<p>A power set of a finite set:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">powerset</span><span class="p">()</span> <span class="o">==</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">EmptySet</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>A power set of an interval:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">powerset</span><span class="p">()</span>
<span class="go">PowerSet(Interval(1, 2))</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r689"><span class="brackets"><a class="fn-backref" href="#id2">R689</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Power_set">https://en.wikipedia.org/wiki/Power_set</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.sup">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">sup</span></span><a class="headerlink" href="#sympy.sets.sets.Set.sup" title="Permalink to this definition">¶</a></dt>
<dd><p>The supremum of <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">sup</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">sup</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.symmetric_difference">
<span class="sig-name descname"><span class="pre">symmetric_difference</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L224-L246"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.symmetric_difference" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns symmetric difference of <code class="docutils literal notranslate"><span class="pre">self</span></code> and <code class="docutils literal notranslate"><span class="pre">other</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">symmetric_difference</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Union(Interval.open(-oo, 1), Interval.open(3, oo))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span><span class="o">.</span><span class="n">symmetric_difference</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Union(Interval.open(-oo, 1), Interval.open(10, oo))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">EmptySet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="o">.</span><span class="n">symmetric_difference</span><span class="p">(</span><span class="n">EmptySet</span><span class="p">)</span>
<span class="go">Reals</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r690"><span class="brackets"><a class="fn-backref" href="#id3">R690</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Symmetric_difference">https://en.wikipedia.org/wiki/Symmetric_difference</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Set.union">
<span class="sig-name descname"><span class="pre">union</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L89-L114"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Set.union" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the union of <code class="docutils literal notranslate"><span class="pre">self</span></code> and <code class="docutils literal notranslate"><span class="pre">other</span></code>.</p>
<p class="rubric">Examples</p>
<p>As a shortcut it is possible to use the ‘+’ operator:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">FiniteSet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">Union(Interval(0, 1), Interval(2, 3))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">Union(Interval(0, 1), Interval(2, 3))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="kc">True</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> <span class="o">+</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">Union({3}, Interval.Lopen(1, 2))</span>
</pre></div>
</div>
<p>Similarly it is possible to use the ‘-’ operator for set differences:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="o">-</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">Interval.Lopen(1, 2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="o">-</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Union(Interval.Ropen(1, 2), Interval.Lopen(2, 3))</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.sets.sets.imageset">
<span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">imageset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L2190-L2316"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.imageset" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an image of the set under transformation <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Explanation</p>
<p>If this function can’t compute the image, it returns an
unevaluated ImageSet object.</p>
<div class="math notranslate nohighlight">
\[\{ f(x) \mid x \in \mathrm{self} \}\]</div>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">imageset</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">Lambda</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">imageset</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">Interval(0, 4)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">imageset</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">Interval(0, 4)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">imageset</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)),</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">ImageSet(Lambda(x, sin(x)), Interval(-2, 1))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">imageset</span><span class="p">(</span><span class="n">sin</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">ImageSet(Lambda(x, sin(x)), Interval(-2, 1))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">imageset</span><span class="p">(</span><span class="k">lambda</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">ImageSet(Lambda(y, x + y), Interval(-2, 1))</span>
</pre></div>
</div>
<p>Expressions applied to the set of Integers are simplified
to show as few negatives as possible and linear expressions
are converted to a canonical form. If this is not desirable
then the unevaluated ImageSet should be used.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">imageset</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">5</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">)</span>
<span class="go">ImageSet(Lambda(x, 2*x + 1), Integers)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.fancysets.ImageSet" title="sympy.sets.fancysets.ImageSet"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.sets.fancysets.ImageSet</span></code></a></p>
</div>
</dd></dl>

</section>
</section>
<section id="elementary-sets">
<h2>Elementary Sets<a class="headerlink" href="#elementary-sets" title="Permalink to this headline">¶</a></h2>
<section id="interval">
<h3>Interval<a class="headerlink" href="#interval" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">Interval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">left_open</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">right_open</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L873-L1149"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Interval" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a real interval as a Set.</p>
<dl>
<dt>Usage:</dt><dd><p>Returns an interval with end points “start” and “end”.</p>
<p>For left_open=True (default left_open is False) the interval
will be open on the left. Similarly, for right_open=True the interval
will be open on the right.</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">Interval(0, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="o">.</span><span class="n">Ropen</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">Interval.Ropen(0, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="o">.</span><span class="n">Ropen</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">Interval.Ropen(0, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="o">.</span><span class="n">Lopen</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">Interval.Lopen(0, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">Interval.open(0, 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span>
<span class="go">Interval(0, a)</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<ul class="simple">
<li><p>Only real end points are supported</p></li>
<li><p>Interval(a, b) with a &gt; b will return the empty set</p></li>
<li><p>Use the evalf() method to turn an Interval into an mpmath
‘mpi’ interval instance</p></li>
</ul>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r691"><span class="brackets"><a class="fn-backref" href="#id4">R691</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Interval_(mathematics)">https://en.wikipedia.org/wiki/Interval_%28mathematics%29</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.Lopen">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">Lopen</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1030-L1033"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Interval.Lopen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an interval not including the left boundary.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.Ropen">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">Ropen</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1035-L1038"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Interval.Ropen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an interval not including the right boundary.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.as_relational">
<span class="sig-name descname"><span class="pre">as_relational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1100-L1111"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Interval.as_relational" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite an interval in terms of inequalities and logic operators.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.end">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">end</span></span><a class="headerlink" href="#sympy.sets.sets.Interval.end" title="Permalink to this definition">¶</a></dt>
<dd><p>The right end point of ‘self’.</p>
<p>This property takes the same value as the ‘sup’ property.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">end</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.is_left_unbounded">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_left_unbounded</span></span><a class="headerlink" href="#sympy.sets.sets.Interval.is_left_unbounded" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the left endpoint is negative infinity.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.is_right_unbounded">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_right_unbounded</span></span><a class="headerlink" href="#sympy.sets.sets.Interval.is_right_unbounded" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the right endpoint is positive infinity.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.left_open">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">left_open</span></span><a class="headerlink" href="#sympy.sets.sets.Interval.left_open" title="Permalink to this definition">¶</a></dt>
<dd><p>True if <code class="docutils literal notranslate"><span class="pre">self</span></code> is left-open.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">left_open</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">left_open</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">left_open</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">left_open</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.open">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">open</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1025-L1028"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Interval.open" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an interval including neither boundary.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.right_open">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">right_open</span></span><a class="headerlink" href="#sympy.sets.sets.Interval.right_open" title="Permalink to this definition">¶</a></dt>
<dd><p>True if <code class="docutils literal notranslate"><span class="pre">self</span></code> is right-open.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">right_open</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">right_open</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">right_open</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">right_open</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.Interval.start">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">start</span></span><a class="headerlink" href="#sympy.sets.sets.Interval.start" title="Permalink to this definition">¶</a></dt>
<dd><p>The left end point of <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
<p>This property takes the same value as the ‘inf’ property.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">start</span>
<span class="go">0</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</section>
<section id="finiteset">
<h3>FiniteSet<a class="headerlink" href="#finiteset" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.FiniteSet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">FiniteSet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1742-L1966"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.FiniteSet" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a finite set of discrete numbers.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">FiniteSet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">{1, 2, 3, 4}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">3</span> <span class="ow">in</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">members</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="o">*</span><span class="n">members</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span>
<span class="go">{1, 2, 3, 4}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">-</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">{1, 3, 4}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">+</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">{1, 2, 3, 4, 5}</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r692"><span class="brackets"><a class="fn-backref" href="#id5">R692</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Finite_set">https://en.wikipedia.org/wiki/Finite_set</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.FiniteSet.as_relational">
<span class="sig-name descname"><span class="pre">as_relational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1907-L1910"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.FiniteSet.as_relational" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite a FiniteSet in terms of equalities and logic operators.</p>
</dd></dl>

</dd></dl>

</section>
</section>
<section id="compound-sets">
<h2>Compound Sets<a class="headerlink" href="#compound-sets" title="Permalink to this headline">¶</a></h2>
<section id="union">
<h3>Union<a class="headerlink" href="#union" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.Union">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">Union</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1152-L1314"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Union" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a union of sets as a <a class="reference internal" href="#sympy.sets.sets.Set" title="sympy.sets.sets.Set"><code class="xref py py-class docutils literal notranslate"><span class="pre">Set</span></code></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
<span class="go">Union(Interval(1, 2), Interval(3, 4))</span>
</pre></div>
</div>
<p>The Union constructor will always try to merge overlapping intervals,
if possible. For example:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">Interval(1, 3)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.sets.Intersection" title="sympy.sets.sets.Intersection"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Intersection</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r693"><span class="brackets"><a class="fn-backref" href="#id6">R693</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Union_(set_theory)">https://en.wikipedia.org/wiki/Union_%28set_theory%29</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Union.as_relational">
<span class="sig-name descname"><span class="pre">as_relational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1297-L1307"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Union.as_relational" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite a Union in terms of equalities and logic operators.</p>
</dd></dl>

</dd></dl>

</section>
<section id="intersection">
<h3>Intersection<a class="headerlink" href="#intersection" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.Intersection">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">Intersection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1317-L1534"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Intersection" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents an intersection of sets as a <a class="reference internal" href="#sympy.sets.sets.Set" title="sympy.sets.sets.Set"><code class="xref py py-class docutils literal notranslate"><span class="pre">Set</span></code></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Intersection</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Intersection</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
<span class="go">Interval(2, 3)</span>
</pre></div>
</div>
<p>We often use the .intersect method</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">4</span><span class="p">))</span>
<span class="go">Interval(2, 3)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.sets.Union" title="sympy.sets.sets.Union"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Union</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r694"><span class="brackets"><a class="fn-backref" href="#id7">R694</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Intersection_(set_theory)">https://en.wikipedia.org/wiki/Intersection_%28set_theory%29</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Intersection.as_relational">
<span class="sig-name descname"><span class="pre">as_relational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1532-L1534"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Intersection.as_relational" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite an Intersection in terms of equalities and logic operators</p>
</dd></dl>

</dd></dl>

</section>
<section id="productset">
<h3>ProductSet<a class="headerlink" href="#productset" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.ProductSet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">ProductSet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">sets</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">assumptions</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L696-L870"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.ProductSet" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a Cartesian Product of Sets.</p>
<p class="rubric">Explanation</p>
<p>Returns a Cartesian product given several sets as either an iterable
or individual arguments.</p>
<p>Can use ‘*’ operator on any sets for convenient shorthand.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">FiniteSet</span><span class="p">,</span> <span class="n">ProductSet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">I</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">);</span> <span class="n">S</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ProductSet</span><span class="p">(</span><span class="n">I</span><span class="p">,</span> <span class="n">S</span><span class="p">)</span>
<span class="go">ProductSet(Interval(0, 5), {1, 2, 3})</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">in</span> <span class="n">ProductSet</span><span class="p">(</span><span class="n">I</span><span class="p">,</span> <span class="n">S</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c1"># The unit square</span>
<span class="go">ProductSet(Interval(0, 1), Interval(0, 1))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">coin</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="s1">&#39;H&#39;</span><span class="p">,</span> <span class="s1">&#39;T&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">set</span><span class="p">(</span><span class="n">coin</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">{(H, H), (H, T), (T, H), (T, T)}</span>
</pre></div>
</div>
<p>The Cartesian product is not commutative or associative e.g.:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">I</span><span class="o">*</span><span class="n">S</span> <span class="o">==</span> <span class="n">S</span><span class="o">*</span><span class="n">I</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">(</span><span class="n">I</span><span class="o">*</span><span class="n">I</span><span class="p">)</span><span class="o">*</span><span class="n">I</span> <span class="o">==</span> <span class="n">I</span><span class="o">*</span><span class="p">(</span><span class="n">I</span><span class="o">*</span><span class="n">I</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<ul class="simple">
<li><p>Passes most operations down to the argument sets</p></li>
</ul>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r695"><span class="brackets"><a class="fn-backref" href="#id8">R695</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Cartesian_product">https://en.wikipedia.org/wiki/Cartesian_product</a></p>
</dd>
</dl>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.sets.ProductSet.is_iterable">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_iterable</span></span><a class="headerlink" href="#sympy.sets.sets.ProductSet.is_iterable" title="Permalink to this definition">¶</a></dt>
<dd><p>A property method which tests whether a set is iterable or not.
Returns True if set is iterable, otherwise returns False.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">FiniteSet</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">I</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">I</span><span class="o">.</span><span class="n">is_iterable</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">is_iterable</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</section>
<section id="complement">
<h3>Complement<a class="headerlink" href="#complement" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.Complement">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">Complement</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">evaluate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1537-L1623"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Complement" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the set difference or relative complement of a set with
another set.</p>
<p><span class="math notranslate nohighlight">\(A - B = \{x \in A \mid x \notin B\}\)</span></p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Complement</span><span class="p">,</span> <span class="n">FiniteSet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Complement</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
<span class="go">{0, 2}</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.sets.Intersection" title="sympy.sets.sets.Intersection"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Intersection</span></code></a>, <a class="reference internal" href="#sympy.sets.sets.Union" title="sympy.sets.sets.Union"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Union</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r696"><span class="brackets"><a class="fn-backref" href="#id9">R696</a></span></dt>
<dd><p><a class="reference external" href="http://mathworld.wolfram.com/ComplementSet.html">http://mathworld.wolfram.com/ComplementSet.html</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Complement.as_relational">
<span class="sig-name descname"><span class="pre">as_relational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1593-L1601"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Complement.as_relational" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite a complement in terms of equalities and logic
operators</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.Complement.reduce">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">reduce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1570-L1586"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.Complement.reduce" title="Permalink to this definition">¶</a></dt>
<dd><p>Simplify a <a class="reference internal" href="#sympy.sets.sets.Complement" title="sympy.sets.sets.Complement"><code class="xref py py-class docutils literal notranslate"><span class="pre">Complement</span></code></a>.</p>
</dd></dl>

</dd></dl>

</section>
<section id="symmetricdifference">
<h3>SymmetricDifference<a class="headerlink" href="#symmetricdifference" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.SymmetricDifference">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">SymmetricDifference</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">evaluate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1973-L2038"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.SymmetricDifference" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the set of elements which are in either of the
sets and not in their intersection.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">SymmetricDifference</span><span class="p">,</span> <span class="n">FiniteSet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">SymmetricDifference</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">{1, 2, 4, 5}</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.sets.Complement" title="sympy.sets.sets.Complement"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Complement</span></code></a>, <a class="reference internal" href="#sympy.sets.sets.Union" title="sympy.sets.sets.Union"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Union</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r697"><span class="brackets"><a class="fn-backref" href="#id10">R697</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Symmetric_difference">https://en.wikipedia.org/wiki/Symmetric_difference</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.sets.SymmetricDifference.as_relational">
<span class="sig-name descname"><span class="pre">as_relational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L2011-L2019"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.SymmetricDifference.as_relational" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite a symmetric_difference in terms of equalities and
logic operators</p>
</dd></dl>

</dd></dl>

</section>
</section>
<section id="singleton-sets">
<h2>Singleton Sets<a class="headerlink" href="#singleton-sets" title="Permalink to this headline">¶</a></h2>
<section id="emptyset">
<h3>EmptySet<a class="headerlink" href="#emptyset" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.EmptySet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">EmptySet</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1626-L1688"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.EmptySet" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the empty set. The empty set is available as a singleton
as S.EmptySet.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">EmptySet</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">EmptySet</span><span class="p">)</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.sets.UniversalSet" title="sympy.sets.sets.UniversalSet"><code class="xref py py-obj docutils literal notranslate"><span class="pre">UniversalSet</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r698"><span class="brackets"><a class="fn-backref" href="#id11">R698</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Empty_set">https://en.wikipedia.org/wiki/Empty_set</a></p>
</dd>
</dl>
</dd></dl>

</section>
<section id="universalset">
<h3>UniversalSet<a class="headerlink" href="#universalset" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.sets.UniversalSet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.sets.</span></span><span class="sig-name descname"><span class="pre">UniversalSet</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/sets.py#L1691-L1739"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.sets.UniversalSet" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the set of all things.
The universal set is available as a singleton as S.UniversalSet.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">UniversalSet</span>
<span class="go">UniversalSet</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">UniversalSet</span><span class="p">)</span>
<span class="go">Interval(1, 2)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.sets.EmptySet" title="sympy.sets.sets.EmptySet"><code class="xref py py-obj docutils literal notranslate"><span class="pre">EmptySet</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r699"><span class="brackets"><a class="fn-backref" href="#id12">R699</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Universal_set">https://en.wikipedia.org/wiki/Universal_set</a></p>
</dd>
</dl>
</dd></dl>

</section>
</section>
<section id="module-sympy.sets.fancysets">
<span id="special-sets"></span><h2>Special Sets<a class="headerlink" href="#module-sympy.sets.fancysets" title="Permalink to this headline">¶</a></h2>
<section id="naturals">
<h3>Naturals<a class="headerlink" href="#naturals" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Naturals">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">Naturals</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L67-L128"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.Naturals" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the natural numbers (or counting numbers) which are all
positive integers starting from 1. This set is also available as
the Singleton, S.Naturals.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">5</span> <span class="ow">in</span> <span class="n">S</span><span class="o">.</span><span class="n">Naturals</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">iterable</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Naturals</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="go">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Naturals</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">)))</span>
<span class="go">{1, 2, ..., 10}</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#sympy.sets.fancysets.Naturals0" title="sympy.sets.fancysets.Naturals0"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Naturals0</span></code></a></dt><dd><p>non-negative integers (i.e. includes 0, too)</p>
</dd>
<dt><a class="reference internal" href="#sympy.sets.fancysets.Integers" title="sympy.sets.fancysets.Integers"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Integers</span></code></a></dt><dd><p>also includes negative integers</p>
</dd>
</dl>
</div>
</dd></dl>

</section>
<section id="naturals0">
<h3>Naturals0<a class="headerlink" href="#naturals0" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Naturals0">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">Naturals0</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L131-L155"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.Naturals0" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the whole numbers which are all the non-negative integers,
inclusive of zero.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#sympy.sets.fancysets.Naturals" title="sympy.sets.fancysets.Naturals"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Naturals</span></code></a></dt><dd><p>positive integers; does not include 0</p>
</dd>
<dt><a class="reference internal" href="#sympy.sets.fancysets.Integers" title="sympy.sets.fancysets.Integers"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Integers</span></code></a></dt><dd><p>also includes the negative integers</p>
</dd>
</dl>
</div>
</dd></dl>

</section>
<section id="integers">
<h3>Integers<a class="headerlink" href="#integers" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Integers">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">Integers</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L158-L226"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.Integers" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents all integers: positive, negative and zero. This set is also
available as the Singleton, S.Integers.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">5</span> <span class="ow">in</span> <span class="n">S</span><span class="o">.</span><span class="n">Naturals</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">iterable</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="go">-1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">)))</span>
<span class="go">{-4, -3, ..., 4}</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#sympy.sets.fancysets.Naturals0" title="sympy.sets.fancysets.Naturals0"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Naturals0</span></code></a></dt><dd><p>non-negative integers</p>
</dd>
<dt><a class="reference internal" href="#sympy.sets.fancysets.Integers" title="sympy.sets.fancysets.Integers"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Integers</span></code></a></dt><dd><p>positive and negative integers and zero</p>
</dd>
</dl>
</div>
</dd></dl>

</section>
<section id="reals">
<h3>Reals<a class="headerlink" href="#reals" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Reals">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">Reals</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L229-L278"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.Reals" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents all real numbers
from negative infinity to positive infinity,
including all integer, rational and irrational numbers.
This set is also available as the Singleton, S.Reals.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Rational</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">5</span> <span class="ow">in</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Rational</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">in</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pi</span> <span class="ow">in</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">3</span><span class="o">*</span><span class="n">I</span> <span class="ow">in</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">pi</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.fancysets.ComplexRegion" title="sympy.sets.fancysets.ComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ComplexRegion</span></code></a></p>
</div>
</dd></dl>

</section>
<section id="complexes">
<h3>Complexes<a class="headerlink" href="#complexes" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Complexes">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">Complexes</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L1468-L1504"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.Complexes" title="Permalink to this definition">¶</a></dt>
<dd><p>The Set of all complex numbers</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="o">.</span><span class="n">Complexes</span>
<span class="go">Complexes</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span> <span class="o">+</span> <span class="n">I</span> <span class="ow">in</span> <span class="n">S</span><span class="o">.</span><span class="n">Complexes</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.fancysets.Reals" title="sympy.sets.fancysets.Reals"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Reals</span></code></a>, <a class="reference internal" href="#sympy.sets.fancysets.ComplexRegion" title="sympy.sets.fancysets.ComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ComplexRegion</span></code></a></p>
</div>
</dd></dl>

</section>
<section id="imageset">
<h3>ImageSet<a class="headerlink" href="#imageset" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.ImageSet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">ImageSet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">flambda</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">sets</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L281-L504"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.ImageSet" title="Permalink to this definition">¶</a></dt>
<dd><p>Image of a set under a mathematical function. The transformation
must be given as a Lambda function which has as many arguments
as the elements of the set upon which it operates, e.g. 1 argument
when acting on the set of integers or 2 arguments when acting on
a complex region.</p>
<p>This function is not normally called directly, but is called
from <span class="math notranslate nohighlight">\(imageset\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">Dummy</span><span class="p">,</span> <span class="n">Lambda</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.sets</span> <span class="kn">import</span> <span class="n">FiniteSet</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.fancysets</span> <span class="kn">import</span> <span class="n">ImageSet</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">N</span> <span class="o">=</span> <span class="n">S</span><span class="o">.</span><span class="n">Naturals</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">squares</span> <span class="o">=</span> <span class="n">ImageSet</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">),</span> <span class="n">N</span><span class="p">)</span> <span class="c1"># {x**2 for x in N}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">4</span> <span class="ow">in</span> <span class="n">squares</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">5</span> <span class="ow">in</span> <span class="n">squares</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">squares</span><span class="p">)</span>
<span class="go">{1, 4, 9}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">square_iterable</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">squares</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span>
<span class="gp">... </span>    <span class="nb">next</span><span class="p">(</span><span class="n">square_iterable</span><span class="p">)</span>
<span class="go">1</span>
<span class="go">4</span>
<span class="go">9</span>
<span class="go">16</span>
</pre></div>
</div>
<p>If you want to get value for <span class="math notranslate nohighlight">\(x\)</span> = 2, 1/2 etc. (Please check whether the
<span class="math notranslate nohighlight">\(x\)</span> value is in <span class="math notranslate nohighlight">\(base_set\)</span> or not before passing it as args)</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">squares</span><span class="o">.</span><span class="n">lamda</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">squares</span><span class="o">.</span><span class="n">lamda</span><span class="p">(</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
<span class="go">1/4</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">n</span> <span class="o">=</span> <span class="n">Dummy</span><span class="p">(</span><span class="s1">&#39;n&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">solutions</span> <span class="o">=</span> <span class="n">ImageSet</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">n</span><span class="o">*</span><span class="n">pi</span><span class="p">),</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">)</span> <span class="c1"># solutions of sin(x) = 0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dom</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dom</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">solutions</span><span class="p">)</span>
<span class="go">{0}</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.sets.imageset" title="sympy.sets.sets.imageset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.sets.sets.imageset</span></code></a></p>
</div>
</dd></dl>

</section>
<section id="range">
<h3>Range<a class="headerlink" href="#range" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Range">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">Range</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L507-L992"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.Range" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a range of integers. Can be called as Range(stop),
Range(start, stop), or Range(start, stop, step); when step is
not given it defaults to 1.</p>
<p><span class="math notranslate nohighlight">\(Range(stop)\)</span> is the same as <span class="math notranslate nohighlight">\(Range(0, stop, 1)\)</span> and the stop value
(juse as for Python ranges) is not included in the Range values.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Range</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">Range</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
<span class="go">[0, 1, 2]</span>
</pre></div>
</div>
<p>The step can also be negative:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">Range</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">))</span>
<span class="go">[10, 8, 6, 4, 2]</span>
</pre></div>
</div>
<p>The stop value is made canonical so equivalent ranges always
have the same args:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">Range(0, 12, 3)</span>
</pre></div>
</div>
<p>Infinite ranges are allowed. <code class="docutils literal notranslate"><span class="pre">oo</span></code> and <code class="docutils literal notranslate"><span class="pre">-oo</span></code> are never included in the
set (<code class="docutils literal notranslate"><span class="pre">Range</span></code> is always a subset of <code class="docutils literal notranslate"><span class="pre">Integers</span></code>). If the starting point
is infinite, then the final value is <code class="docutils literal notranslate"><span class="pre">stop</span> <span class="pre">-</span> <span class="pre">step</span></code>. To iterate such a
range, it needs to be reversed:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">Range</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="n">r</span><span class="p">))</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">TypeError</span>: <span class="n">Cannot iterate over Range with infinite start</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">next</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">reversed</span><span class="p">))</span>
<span class="go">0</span>
</pre></div>
</div>
<p>Although Range is a set (and supports the normal set
operations) it maintains the order of the elements and can
be used in contexts where <span class="math notranslate nohighlight">\(range\)</span> would be used.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span>
<span class="go">Range(4, 8, 2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">_</span><span class="p">)</span>
<span class="go">[4, 6]</span>
</pre></div>
</div>
<p>Although slicing of a Range will always return a Range – possibly
empty – an empty set will be returned from any intersection that
is empty:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="mi">3</span><span class="p">)[:</span><span class="mi">0</span><span class="p">]</span>
<span class="go">Range(0, 0, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">EmptySet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Range</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
<p>Range will accept symbolic arguments but has very limited support
for doing anything other than displaying the Range:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span><span class="o">.</span><span class="n">start</span>
<span class="go">i</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span><span class="o">.</span><span class="n">inf</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ValueError</span>: <span class="n">invalid method for symbolic range</span>
</pre></div>
</div>
<p>Better success will be had when using integer symbols:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">n</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="n">integer</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">Range</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">n</span> <span class="o">+</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">inf</span>
<span class="go">n</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">r</span><span class="p">)</span>
<span class="go">{n, n + 3, ..., n + 18}</span>
</pre></div>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Range.as_relational">
<span class="sig-name descname"><span class="pre">as_relational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L961-L992"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.Range.as_relational" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite a Range in terms of equalities and logic operators.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.fancysets.Range.reversed">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">reversed</span></span><a class="headerlink" href="#sympy.sets.fancysets.Range.reversed" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an equivalent Range in the opposite order.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Range</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Range</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="o">.</span><span class="n">reversed</span>
<span class="go">Range(9, -1, -1)</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</section>
<section id="complexregion">
<h3>ComplexRegion<a class="headerlink" href="#complexregion" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.ComplexRegion">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">ComplexRegion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sets</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L1082-L1354"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.ComplexRegion" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the Set of all Complex Numbers. It can represent a
region of Complex Plane in both the standard forms Polar and
Rectangular coordinates.</p>
<ul class="simple">
<li><p>Polar Form
Input is in the form of the ProductSet or Union of ProductSets
of the intervals of r and theta, &amp; use the flag polar=True.</p></li>
</ul>
<p>Z = {z in C | z = r*[cos(theta) + I*sin(theta)], r in [r], theta in [theta]}</p>
<ul class="simple">
<li><p>Rectangular Form
Input is in the form of the ProductSet or Union of ProductSets
of interval of x and y the of the Complex numbers in a Plane.
Default input type is in rectangular form.</p></li>
</ul>
<p>Z = {z in C | z = x + I*y, x in [Re(z)], y in [Im(z)]}</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.fancysets</span> <span class="kn">import</span> <span class="n">ComplexRegion</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">I</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">)</span>  <span class="c1"># Rectangular Form</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span>
<span class="go">CartesianComplexRegion(ProductSet(Interval(2, 3), Interval(4, 6)))</span>
</pre></div>
</div>
<ul class="simple">
<li><p>c1 represents the rectangular region in complex plane
surrounded by the coordinates (2, 4), (3, 4), (3, 6) and
(2, 6), of the four vertices.</p></li>
</ul>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Union</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="n">b</span><span class="o">*</span><span class="n">c</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span>
<span class="go">CartesianComplexRegion(Union(ProductSet(Interval(2, 3), Interval(4, 6)), ProductSet(Interval(4, 6), Interval(1, 8))))</span>
</pre></div>
</div>
<ul class="simple">
<li><p>c2 represents the Union of two rectangular regions in complex
plane. One of them surrounded by the coordinates of c1 and
other surrounded by the coordinates (4, 1), (6, 1), (6, 8) and
(4, 8).</p></li>
</ul>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="mf">2.5</span> <span class="o">+</span> <span class="mf">4.5</span><span class="o">*</span><span class="n">I</span> <span class="ow">in</span> <span class="n">c1</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mf">2.5</span> <span class="o">+</span> <span class="mf">6.5</span><span class="o">*</span><span class="n">I</span> <span class="ow">in</span> <span class="n">c1</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">theta</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">S</span><span class="o">.</span><span class="n">Pi</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">r</span><span class="o">*</span><span class="n">theta</span><span class="p">,</span> <span class="n">polar</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>  <span class="c1"># Polar Form</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span>  <span class="c1"># unit Disk</span>
<span class="go">PolarComplexRegion(ProductSet(Interval(0, 1), Interval.Ropen(0, 2*pi)))</span>
</pre></div>
</div>
<ul class="simple">
<li><p>c2 represents the region in complex plane inside the
Unit Disk centered at the origin.</p></li>
</ul>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="mf">0.5</span> <span class="o">+</span> <span class="mf">0.5</span><span class="o">*</span><span class="n">I</span> <span class="ow">in</span> <span class="n">c2</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">I</span> <span class="ow">in</span> <span class="n">c2</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unit_disk</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">*</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">S</span><span class="o">.</span><span class="n">Pi</span><span class="p">),</span> <span class="n">polar</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">upper_half_unit_disk</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">*</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Pi</span><span class="p">),</span> <span class="n">polar</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">intersection</span> <span class="o">=</span> <span class="n">unit_disk</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">upper_half_unit_disk</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">intersection</span>
<span class="go">PolarComplexRegion(ProductSet(Interval(0, 1), Interval(0, pi)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">intersection</span> <span class="o">==</span> <span class="n">upper_half_unit_disk</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.fancysets.CartesianComplexRegion" title="sympy.sets.fancysets.CartesianComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CartesianComplexRegion</span></code></a>, <a class="reference internal" href="#sympy.sets.fancysets.PolarComplexRegion" title="sympy.sets.fancysets.PolarComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PolarComplexRegion</span></code></a>, <a class="reference internal" href="#sympy.sets.fancysets.Complexes" title="sympy.sets.fancysets.Complexes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Complexes</span></code></a></p>
</div>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.fancysets.ComplexRegion.a_interval">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">a_interval</span></span><a class="headerlink" href="#sympy.sets.fancysets.ComplexRegion.a_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the union of intervals of <span class="math notranslate nohighlight">\(x\)</span> when, self is in
rectangular form, or the union of intervals of <span class="math notranslate nohighlight">\(r\)</span> when
self is in polar form.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">ComplexRegion</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span><span class="o">.</span><span class="n">a_interval</span>
<span class="go">Interval(2, 3)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Union</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="n">b</span><span class="o">*</span><span class="n">c</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span><span class="o">.</span><span class="n">a_interval</span>
<span class="go">Union(Interval(2, 3), Interval(4, 5))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.fancysets.ComplexRegion.b_interval">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">b_interval</span></span><a class="headerlink" href="#sympy.sets.fancysets.ComplexRegion.b_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the union of intervals of <span class="math notranslate nohighlight">\(y\)</span> when, self is in
rectangular form, or the union of intervals of <span class="math notranslate nohighlight">\(theta\)</span>
when self is in polar form.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">ComplexRegion</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span><span class="o">.</span><span class="n">b_interval</span>
<span class="go">Interval(4, 5)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Union</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="n">b</span><span class="o">*</span><span class="n">c</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span><span class="o">.</span><span class="n">b_interval</span>
<span class="go">Interval(1, 7)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.sets.fancysets.ComplexRegion.from_real">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_real</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sets</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L1300-L1317"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.ComplexRegion.from_real" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts given subset of real numbers to a complex region.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">ComplexRegion</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">unit</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ComplexRegion</span><span class="o">.</span><span class="n">from_real</span><span class="p">(</span><span class="n">unit</span><span class="p">)</span>
<span class="go">CartesianComplexRegion(ProductSet(Interval(0, 1), {0}))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.fancysets.ComplexRegion.psets">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">psets</span></span><a class="headerlink" href="#sympy.sets.fancysets.ComplexRegion.psets" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a tuple of sets (ProductSets) input of the self.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">ComplexRegion</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span><span class="o">.</span><span class="n">psets</span>
<span class="go">(ProductSet(Interval(2, 3), Interval(4, 5)),)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Union</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="n">b</span><span class="o">*</span><span class="n">c</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span><span class="o">.</span><span class="n">psets</span>
<span class="go">(ProductSet(Interval(2, 3), Interval(4, 5)), ProductSet(Interval(4, 5), Interval(1, 7)))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.sets.fancysets.ComplexRegion.sets">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">sets</span></span><a class="headerlink" href="#sympy.sets.fancysets.ComplexRegion.sets" title="Permalink to this definition">¶</a></dt>
<dd><p>Return raw input sets to the self.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">ComplexRegion</span><span class="p">,</span> <span class="n">Union</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C1</span><span class="o">.</span><span class="n">sets</span>
<span class="go">ProductSet(Interval(2, 3), Interval(4, 5))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Union</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="n">b</span><span class="o">*</span><span class="n">c</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C2</span><span class="o">.</span><span class="n">sets</span>
<span class="go">Union(ProductSet(Interval(2, 3), Interval(4, 5)), ProductSet(Interval(4, 5), Interval(1, 7)))</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.CartesianComplexRegion">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">CartesianComplexRegion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sets</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L1357-L1410"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.CartesianComplexRegion" title="Permalink to this definition">¶</a></dt>
<dd><p>Set representing a square region of the complex plane.</p>
<p>Z = {z in C | z = x + I*y, x in [Re(z)], y in [Im(z)]}</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.fancysets</span> <span class="kn">import</span> <span class="n">ComplexRegion</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.sets</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">region</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="o">*</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">I</span> <span class="ow">in</span> <span class="n">region</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">5</span><span class="o">*</span><span class="n">I</span> <span class="ow">in</span> <span class="n">region</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.fancysets.ComplexRegion" title="sympy.sets.fancysets.ComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ComplexRegion</span></code></a>, <a class="reference internal" href="#sympy.sets.fancysets.PolarComplexRegion" title="sympy.sets.fancysets.PolarComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PolarComplexRegion</span></code></a>, <a class="reference internal" href="#sympy.sets.fancysets.Complexes" title="sympy.sets.fancysets.Complexes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Complexes</span></code></a></p>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.fancysets.PolarComplexRegion">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">PolarComplexRegion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sets</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L1413-L1465"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.PolarComplexRegion" title="Permalink to this definition">¶</a></dt>
<dd><p>Set representing a polar region of the complex plane.</p>
<p>Z = {z in C | z = r*[cos(theta) + I*sin(theta)], r in [r], theta in [theta]}</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.fancysets</span> <span class="kn">import</span> <span class="n">ComplexRegion</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">oo</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rset</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">oo</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">thetaset</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">pi</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">upper_half_plane</span> <span class="o">=</span> <span class="n">ComplexRegion</span><span class="p">(</span><span class="n">rset</span> <span class="o">*</span> <span class="n">thetaset</span><span class="p">,</span> <span class="n">polar</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span> <span class="o">+</span> <span class="n">I</span> <span class="ow">in</span> <span class="n">upper_half_plane</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span> <span class="o">-</span> <span class="n">I</span> <span class="ow">in</span> <span class="n">upper_half_plane</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.sets.fancysets.ComplexRegion" title="sympy.sets.fancysets.ComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ComplexRegion</span></code></a>, <a class="reference internal" href="#sympy.sets.fancysets.CartesianComplexRegion" title="sympy.sets.fancysets.CartesianComplexRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CartesianComplexRegion</span></code></a>, <a class="reference internal" href="#sympy.sets.fancysets.Complexes" title="sympy.sets.fancysets.Complexes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Complexes</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.sets.fancysets.normalize_theta_set">
<span class="sig-prename descclassname"><span class="pre">sympy.sets.fancysets.</span></span><span class="sig-name descname"><span class="pre">normalize_theta_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theta</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/fancysets.py#L997-L1079"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.fancysets.normalize_theta_set" title="Permalink to this definition">¶</a></dt>
<dd><p>Normalize a Real Set <span class="math notranslate nohighlight">\(theta\)</span> in the Interval [0, 2*pi). It returns
a normalized value of theta in the Set. For Interval, a maximum of
one cycle [0, 2*pi], is returned i.e. for theta equal to [0, 10*pi],
returned normalized value would be [0, 2*pi). As of now intervals
with end points as non-multiples of <span class="math notranslate nohighlight">\(pi\)</span> is not supported.</p>
<dl class="field-list">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>The algorithms for Normalizing theta Set are not yet
implemented.</p>
</div></blockquote>
<p><strong>ValueError</strong></p>
<blockquote>
<div><p>The input is not valid, i.e. the input is not a real set.</p>
</div></blockquote>
<p><strong>RuntimeError</strong></p>
<blockquote>
<div><p>It is a bug, please report to the github issue tracker.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.fancysets</span> <span class="kn">import</span> <span class="n">normalize_theta_set</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">FiniteSet</span><span class="p">,</span> <span class="n">pi</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_theta_set</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">9</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="o">*</span><span class="n">pi</span><span class="p">))</span>
<span class="go">Interval(pi/2, pi)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_theta_set</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">))</span>
<span class="go">Interval.Ropen(0, 2*pi)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_theta_set</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">))</span>
<span class="go">Union(Interval(0, pi/2), Interval.Ropen(3*pi/2, 2*pi))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_theta_set</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">4</span><span class="o">*</span><span class="n">pi</span><span class="p">,</span> <span class="mi">3</span><span class="o">*</span><span class="n">pi</span><span class="p">))</span>
<span class="go">Interval.Ropen(0, 2*pi)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_theta_set</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">))</span>
<span class="go">Interval(pi/2, 3*pi/2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_theta_set</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="mi">3</span><span class="o">*</span><span class="n">pi</span><span class="p">))</span>
<span class="go">{0, pi}</span>
</pre></div>
</div>
</dd></dl>

</section>
</section>
<section id="module-sympy.sets.powerset">
<span id="power-sets"></span><h2>Power sets<a class="headerlink" href="#module-sympy.sets.powerset" title="Permalink to this headline">¶</a></h2>
<section id="powerset">
<h3>PowerSet<a class="headerlink" href="#powerset" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.powerset.PowerSet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.powerset.</span></span><span class="sig-name descname"><span class="pre">PowerSet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">evaluate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/powerset.py#L10-L117"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.powerset.PowerSet" title="Permalink to this definition">¶</a></dt>
<dd><p>A symbolic object representing a power set.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>arg</strong> : Set</p>
<blockquote>
<div><p>The set to take power of.</p>
</div></blockquote>
<p><strong>evaluate</strong> : bool</p>
<blockquote>
<div><p>The flag to control evaluation.</p>
<p>If the evaluation is disabled for finite sets, it can take
advantage of using subset test as a membership test.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Power set <span class="math notranslate nohighlight">\(\mathcal{P}(S)\)</span> is defined as a set containing all the
subsets of <span class="math notranslate nohighlight">\(S\)</span>.</p>
<p>If the set <span class="math notranslate nohighlight">\(S\)</span> is a finite set, its power set would have
<span class="math notranslate nohighlight">\(2^{\left| S \right|}\)</span> elements, where <span class="math notranslate nohighlight">\(\left| S \right|\)</span> denotes
the cardinality of <span class="math notranslate nohighlight">\(S\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.powerset</span> <span class="kn">import</span> <span class="n">PowerSet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">FiniteSet</span>
</pre></div>
</div>
<p>A power set of a finite set:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PowerSet</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">PowerSet({1, 2, 3})</span>
</pre></div>
</div>
<p>A power set of an empty set:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PowerSet</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">EmptySet</span><span class="p">)</span>
<span class="go">PowerSet(EmptySet)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PowerSet</span><span class="p">(</span><span class="n">PowerSet</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">EmptySet</span><span class="p">))</span>
<span class="go">PowerSet(PowerSet(EmptySet))</span>
</pre></div>
</div>
<p>A power set of an infinite set:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PowerSet</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">PowerSet(Reals)</span>
</pre></div>
</div>
<p>Evaluating the power set of a finite set to its explicit form:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PowerSet</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">rewrite</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">)</span>
<span class="go">FiniteSet(EmptySet, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3})</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r700"><span class="brackets"><a class="fn-backref" href="#id13">R700</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Power_set">https://en.wikipedia.org/wiki/Power_set</a></p>
</dd>
<dt class="label" id="r701"><span class="brackets"><a class="fn-backref" href="#id14">R701</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Axiom_of_power_set">https://en.wikipedia.org/wiki/Axiom_of_power_set</a></p>
</dd>
</dl>
</dd></dl>

</section>
<section id="iteration-over-sets">
<h3>Iteration over sets<a class="headerlink" href="#iteration-over-sets" title="Permalink to this headline">¶</a></h3>
<p>For set unions, <span class="math notranslate nohighlight">\(\{a, b\} \cup \{x, y\}\)</span> can be treated as
<span class="math notranslate nohighlight">\(\{a, b, x, y\}\)</span> for iteration regardless of the distinctiveness of
the elements, however, for set intersections, assuming that
<span class="math notranslate nohighlight">\(\{a, b\} \cap \{x, y\}\)</span> is <span class="math notranslate nohighlight">\(\varnothing\)</span> or <span class="math notranslate nohighlight">\(\{a, b \}\)</span> would not
always be valid, since some of <span class="math notranslate nohighlight">\(a\)</span>, <span class="math notranslate nohighlight">\(b\)</span>, <span class="math notranslate nohighlight">\(x\)</span> or <span class="math notranslate nohighlight">\(y\)</span> may or may not be
the elements of the intersection.</p>
<p>Iterating over the elements of a set involving intersection, complement,
or symmetric difference yields (possibly duplicate) elements of the set
provided that all elements are known to be the elements of the set.
If any element cannot be determined to be a member of a set then the
iteration gives <code class="docutils literal notranslate"><span class="pre">TypeError</span></code>.
This happens in the same cases where <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">in</span> <span class="pre">y</span></code> would give an error.</p>
<p>There are some reasons to implement like this, even if it breaks the
consistency with how the python set iterator works.
We keep in mind that sympy set comprehension like <code class="docutils literal notranslate"><span class="pre">FiniteSet(*s)</span></code> from
a existing sympy sets could be a common usage.
And this approach would make <code class="docutils literal notranslate"><span class="pre">FiniteSet(*s)</span></code> to be consistent with any
symbolic set processing methods like <code class="docutils literal notranslate"><span class="pre">FiniteSet(*simplify(s))</span></code>.</p>
</section>
</section>
<section id="module-sympy.sets.conditionset">
<span id="condition-sets"></span><h2>Condition Sets<a class="headerlink" href="#module-sympy.sets.conditionset" title="Permalink to this headline">¶</a></h2>
<section id="conditionset">
<h3>ConditionSet<a class="headerlink" href="#conditionset" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.conditionset.ConditionSet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.conditionset.</span></span><span class="sig-name descname"><span class="pre">ConditionSet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sym</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">base_set</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">UniversalSet</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/conditionset.py#L20-L237"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.conditionset.ConditionSet" title="Permalink to this definition">¶</a></dt>
<dd><p>Set of elements which satisfies a given condition.</p>
<p>{x | condition(x) is True for x in S}</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">ConditionSet</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">Eq</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sin_sols</span> <span class="o">=</span> <span class="n">ConditionSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">Eq</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">2</span><span class="o">*</span><span class="n">pi</span> <span class="ow">in</span> <span class="n">sin_sols</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pi</span><span class="o">/</span><span class="mi">2</span> <span class="ow">in</span> <span class="n">sin_sols</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">3</span><span class="o">*</span><span class="n">pi</span> <span class="ow">in</span> <span class="n">sin_sols</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">5</span> <span class="ow">in</span> <span class="n">ConditionSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">&gt;</span> <span class="mi">4</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>If the value is not in the base set, the result is false:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="mi">5</span> <span class="ow">in</span> <span class="n">ConditionSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">&gt;</span> <span class="mi">4</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<p>Symbols with assumptions should be avoided or else the
condition may evaluate without consideration of the set:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">n</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="n">negative</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cond</span> <span class="o">=</span> <span class="p">(</span><span class="n">n</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">);</span> <span class="n">cond</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ConditionSet</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">cond</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">)</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
<p>Only free symbols can be changed by using <span class="math notranslate nohighlight">\(subs\)</span>:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">ConditionSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">,</span> <span class="p">{</span><span class="n">x</span><span class="p">,</span> <span class="n">z</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span><span class="o">.</span><span class="n">subs</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">ConditionSet(x, x &lt; 1, {y, z})</span>
</pre></div>
</div>
<p>To check if <code class="docutils literal notranslate"><span class="pre">pi</span></code> is in <code class="docutils literal notranslate"><span class="pre">c</span></code> use:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pi</span> <span class="ow">in</span> <span class="n">c</span>
<span class="go">False</span>
</pre></div>
</div>
<p>If no base set is specified, the universal set is implied:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ConditionSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">base_set</span>
<span class="go">UniversalSet</span>
</pre></div>
</div>
<p>Only symbols or symbol-like expressions can be used:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ConditionSet</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ValueError</span>: <span class="n">non-symbol dummy not recognized in condition</span>
</pre></div>
</div>
<p>When the base set is a ConditionSet, the symbols will be
unified if possible with preference for the outermost symbols:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ConditionSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span> <span class="o">&lt;</span> <span class="n">y</span><span class="p">,</span> <span class="n">ConditionSet</span><span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">z</span> <span class="o">+</span> <span class="n">y</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">))</span>
<span class="go">ConditionSet(x, (x &lt; y) &amp; (x + y &lt; 2), Integers)</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="relations-on-sets">
<h3>Relations on sets<a class="headerlink" href="#relations-on-sets" title="Permalink to this headline">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.sets.conditionset.Contains">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.sets.conditionset.</span></span><span class="sig-name descname"><span class="pre">Contains</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/sets/contains.py#L7-L49"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.sets.conditionset.Contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Asserts that x is an element of the set S.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets.contains</span> <span class="kn">import</span> <span class="n">Contains</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Contains</span><span class="p">(</span><span class="n">Integer</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">S</span><span class="o">.</span><span class="n">Integers</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Contains</span><span class="p">(</span><span class="n">Integer</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">),</span> <span class="n">S</span><span class="o">.</span><span class="n">Naturals</span><span class="p">)</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">i</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;i&#39;</span><span class="p">,</span> <span class="n">integer</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Contains</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Naturals</span><span class="p">)</span>
<span class="go">Contains(i, Naturals)</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r702"><span class="brackets"><a class="fn-backref" href="#id15">R702</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Element_(mathematics)">https://en.wikipedia.org/wiki/Element_%28mathematics%29</a></p>
</dd>
</dl>
</dd></dl>

</section>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Sets</a><ul>
<li><a class="reference internal" href="#module-sympy.sets.sets">Basic Sets</a><ul>
<li><a class="reference internal" href="#set">Set</a></li>
</ul>
</li>
<li><a class="reference internal" href="#elementary-sets">Elementary Sets</a><ul>
<li><a class="reference internal" href="#interval">Interval</a></li>
<li><a class="reference internal" href="#finiteset">FiniteSet</a></li>
</ul>
</li>
<li><a class="reference internal" href="#compound-sets">Compound Sets</a><ul>
<li><a class="reference internal" href="#union">Union</a></li>
<li><a class="reference internal" href="#intersection">Intersection</a></li>
<li><a class="reference internal" href="#productset">ProductSet</a></li>
<li><a class="reference internal" href="#complement">Complement</a></li>
<li><a class="reference internal" href="#symmetricdifference">SymmetricDifference</a></li>
</ul>
</li>
<li><a class="reference internal" href="#singleton-sets">Singleton Sets</a><ul>
<li><a class="reference internal" href="#emptyset">EmptySet</a></li>
<li><a class="reference internal" href="#universalset">UniversalSet</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sympy.sets.fancysets">Special Sets</a><ul>
<li><a class="reference internal" href="#naturals">Naturals</a></li>
<li><a class="reference internal" href="#naturals0">Naturals0</a></li>
<li><a class="reference internal" href="#integers">Integers</a></li>
<li><a class="reference internal" href="#reals">Reals</a></li>
<li><a class="reference internal" href="#complexes">Complexes</a></li>
<li><a class="reference internal" href="#imageset">ImageSet</a></li>
<li><a class="reference internal" href="#range">Range</a></li>
<li><a class="reference internal" href="#complexregion">ComplexRegion</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sympy.sets.powerset">Power sets</a><ul>
<li><a class="reference internal" href="#powerset">PowerSet</a></li>
<li><a class="reference internal" href="#iteration-over-sets">Iteration over sets</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sympy.sets.conditionset">Condition Sets</a><ul>
<li><a class="reference internal" href="#conditionset">ConditionSet</a></li>
<li><a class="reference internal" href="#relations-on-sets">Relations on sets</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="series/limitseq.html"
                        title="previous chapter">Limits of Sequences</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="simplify/index.html"
                        title="next chapter">Simplify</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/modules/sets.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="simplify/index.html" title="Simplify"
             >next</a> |</li>
        <li class="right" >
          <a href="series/limitseq.html" title="Limits of Sequences"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Sets</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/sets.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:25:42 GMT -->
</html>